package com.meilingcloud.biobank.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meilingcloud.biobank.domain.StockSamples;
import com.meilingcloud.biobank.mapper.StockSamplesMapper;
import com.meilingcloud.biobank.service.IStockSamplesService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 出入库单据与样本复份关联 Service业务层处理
 *
 * @author chenl
 * @date 2021-03-15
 */
@Service
public class StockSamplesServiceImpl extends ServiceImpl<StockSamplesMapper, StockSamples> implements IStockSamplesService {

    @Override
    public List<StockSamples> queryList(StockSamples stockSamples) {
        LambdaQueryWrapper<StockSamples> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(stockSamples.getStockId())) {
            lqw.eq(StockSamples::getStockId, stockSamples.getStockId());
        }
        if (stockSamples.getSampBackupId() != null) {
            lqw.eq(StockSamples::getSampBackupId, stockSamples.getSampBackupId());
        }
        return this.list(lqw);
    }

    @Override
    public List<StockSamples> getStockSamplesByOrder(String stockId) {
        return this.baseMapper.selectStockSampleByOrder(stockId);
    }
}
